package com.gitee.cui.server.starter;

import com.gitee.cui.server.server.ChatServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * 聊天程序服务端启动类
 * @author cuiqingqiang
 * @version 1.0
 * @date 2021/10/28 10:31
 **/
@Slf4j
@Configuration
@ComponentScan("com.gitee.cui.server")
@SpringBootApplication
public class ServerApplication {

    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(ServerApplication.class, args);

        startChatServer(context);
    }

    /**
     * 启动聊天服务端
     * @param context 应用上下文
     */
    private static void startChatServer(ApplicationContext context) {
        ChatServer chatServer = context.getBean(ChatServer.class);
        chatServer.runServer();
    }
}
